﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace WpfApp1
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            StateMachine stateMachine = new StateMachine(State.A);
            stateMachine.TriggerFun(Trigger.GoToA);
            stateMachine.TriggerFun(Trigger.GoToC);
            stateMachine.TriggerFun(Trigger.GoToB);
        }
    }
    // 定义状态枚举
    public enum State
    {
        A,
        B,
        C
    }

    public enum Trigger
    {
        GoToB,
        GoToC,
        GoToA
    }

    public class StateMachine
    {
        private State _state;
        public State CurrentState => _state;

        public StateMachine(State initialState)
        {
            _state = initialState;
        }

        public void TriggerFun(Trigger trigger)
        {
            switch (trigger)
            {
                case Trigger.GoToB:
                    _state = State.B;
                    break;
                case Trigger.GoToC:
                    _state = State.C;
                    break;
                case Trigger.GoToA:
                    _state = State.A;
                    break;
            }

            // 执行状态相关的行为
            ExecuteStateActions();
        }

        private void ExecuteStateActions()
        {
            switch (_state)
            {
                case State.A:
                    // 执行状态A的行为
                    Debug.WriteLine("执行A");
                    break;
                case State.B:
                    // 执行状态B的行为
                    Debug.WriteLine("执行B");
                    break;
                case State.C:
                    // 执行状态C的行为
                    Debug.WriteLine("执行C");
                    break;
            }
        }

    
    }
}
